package com.example.demo.controller;


import com.example.demo.controller.viewobject.UserRoleIdListView;
import com.example.demo.responsehandler.ResponseUtil;
import com.example.demo.service.ISysAclModuleService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.example.demo.codegenerator.BaseController;

import java.io.IOException;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author Webgasd
 * @since 2021-04-25
 */
@RestController
@RequestMapping("/demo/sys-acl-module")
@Api(tags = {"权限模块关联控制器"})
public class SysAclModuleController extends BaseController {
    @Autowired
    private ISysAclModuleService sysAclModuleService;

    @ApiOperation(value = "获取权限树")
    @ApiImplicitParams(value = {@ApiImplicitParam(name = "APP_KEY", value = "拦截器验证K", dataType = "String", defaultValue = "111", example = "111", required = true, paramType = "header"),
            @ApiImplicitParam(name = "SECRET", value = "拦截器验证V", dataType = "String", defaultValue = "111", example = "111", required = true, paramType = "header")})
    @GetMapping("/tree")
    public void tree() throws IOException {
        ResponseUtil.showMessage("200", "请求权限树成功", sysAclModuleService.aclModuleTree());
    }

    @ApiOperation(value = "获取某一角色的权限树")
    @ApiImplicitParams(value = {@ApiImplicitParam(name = "APP_KEY", value = "拦截器验证K", dataType = "String", defaultValue = "111", example = "111", required = true, paramType = "header"),
            @ApiImplicitParam(name = "SECRET", value = "拦截器验证V", dataType = "String", defaultValue = "111", example = "111", required = true, paramType = "header")})
    @GetMapping("/getRoleTreeByRoleId")
    public void getRoleTreeByRoleId(UserRoleIdListView userRoleIdListView) throws IOException {
        ResponseUtil.showMessage("200", "请求角色权限树成功", sysAclModuleService.getRoleTreeByRoleId(userRoleIdListView.getRoleId(), userRoleIdListView.getUserRoleIdList()));
    }
}
